import *as types from '../mutation-types';

import Vue from 'vue';
const context = {
    state: {
        authorization: {
            token: ''
        },
    },
    actions: {
        setAuthorization({commit},value) {
            Vue.ls.remove(types.AUTHORIZATION);
            commit(types.AUTHORIZATION,value);
        },
        logout ({commit}) {
            return new Promise(resolve => {
                commit(types.AUTHORIZATION,{});
                Vue.ls.remove(types.AUTHORIZATION);
                resolve();
            });
        },
    },
    mutations: {
        //权限token
        [types.AUTHORIZATION] (state,value) {
            Vue.ls.set(types.AUTHORIZATION,value);
            state.authorization = value;
        },
    }
};
export default context;
